package com.toumy.config;

import com.qcloud.cos.COSClient;
import com.qcloud.cos.ClientConfig;
import com.qcloud.cos.auth.BasicCOSCredentials;
import com.qcloud.cos.auth.COSCredentials;
import com.qcloud.cos.region.Region;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class CosConfig {
    @Value("${cos.SECRET_ID}")
    private String SECRET_ID;
    @Value("${cos.SECRET_KEY}")
    private String SECRET_KEY;
    @Value("${cos.REGION}")
    private String COS_REGION;
    @Value("${cos.Bucket_name}")
    private String Bucket_name;

    @Bean
    public COSClient getCosClient() {
        COSCredentials cred = new BasicCOSCredentials(SECRET_ID, SECRET_KEY);
        Region region = new Region(COS_REGION);
        ClientConfig clientConfig = new ClientConfig(region);

        return new COSClient(cred, clientConfig);
    }
}